package rpg.oop;
import acm.gui.HPanel;

import static rpg.oop.RPG.randomGenerator;
public class Enemy extends Creature {

    public final String[] ENEMY_NAMES = {"袭梦垂血", "封秦鞅", "闽于修", "陵胡崇", "纳兰穆", "译成", "血梅泪", "韵灵", "萝丝"};           // 敌人名字
    public final String[] ENEMY_ROLES = {"浪人", "剑客", "神算子", "酒鬼", "药师", "阵法师", "行僧", "刺客", "血刀"};     // 敌人角色
    public String role;



    Player player = new Player();

    /**
     * 随机产生一个敌人，并设置好该敌人的各种属性
     */
    public void initialize(Player other) {
        int index;  // 用于储存数组下标

        // 随机选择一个名字
        index = randomGenerator.nextInt(0, ENEMY_NAMES.length - 1);
        name = ENEMY_NAMES[index];

        // 随机选择一个角色
        index = randomGenerator.nextInt(0, ENEMY_ROLES.length - 1);
        role = ENEMY_ROLES[index];

        // 该敌人的各种属性
        int baseHp;                 // 基础血量
        int baseAttack;             // 基础攻击力
        int hpMaxIncrease;          // 每升一级，血量最大增加多少
        int attackMaxIncrease;      // 每升一级，攻击力最大增加多少

        // 不同角色有不同的基础属性和成长属性
          switch (role) {
            case "浪人":
                baseHp = 16;
                baseAttack = 10;
                hpMaxIncrease = 12;
                attackMaxIncrease = 7;
                break;
            case "剑客":
                baseHp = 13;
                baseAttack = 13;
                hpMaxIncrease = 10;
                attackMaxIncrease = 9;
                break;
            case "神算子":
                baseHp = 12;
                baseAttack = 14;
                hpMaxIncrease = 8;
                attackMaxIncrease = 11;
                break;
            //"浪人", "剑客", "刀斧手","","马弓手","药师","阵法师","行僧","刺客"
            case "酒鬼":
                baseHp = 15;
                baseAttack = 10;
                hpMaxIncrease = 10;
                attackMaxIncrease = 7;
                break;
            case "行僧":
                baseHp = 14;
                baseAttack = 10;
                hpMaxIncrease = 12;
                attackMaxIncrease = 7;
                break;
            case "刺客":
                baseHp = 16;
                baseAttack = 10;
                hpMaxIncrease = 9;
                attackMaxIncrease = 7;
                break;
            case "阵法师":
                baseHp = 15;
                baseAttack = 10;
                hpMaxIncrease = 10;
                attackMaxIncrease = 8;
                break;
            case "药师":
                baseHp = 11;
                baseAttack = 15;
                hpMaxIncrease = 11;
                attackMaxIncrease = 7;
                break;
            case "血刀":
                baseHp = 16;
                baseAttack = 16;
                hpMaxIncrease = 12;
                attackMaxIncrease = 7;
                break;
            default:
                baseHp = 0;
                baseAttack = 0;
                hpMaxIncrease = 0;
                attackMaxIncrease = 0;
                break;
        }

        // 随机生成该敌人1级时的属性
        maxHp = (randomGenerator.nextInt(1, 6) + baseHp);
        maxAtt = (randomGenerator.nextInt(1, 6) + baseAttack);
        minAtt = (maxAtt - 3);

        // 让该敌人升到跟玩家同一等级，以保持游戏的平衡性
        for (level = 1; level <other.level ; level++) {
            if (level < 8) {

                maxHp += randomGenerator.nextInt(0, hpMaxIncrease);
                maxAtt += randomGenerator.nextInt(0, attackMaxIncrease);
            } else {
                maxHp += 2 * randomGenerator.nextInt(0, hpMaxIncrease);
                maxAtt += randomGenerator.nextInt(0, attackMaxIncrease);
            }
        }
        // 将该敌人设置为满血
        curHp = maxHp;
    }

        /**
         * 判断敌人是否已经死亡
         *
         * @return 死亡返回true，未死亡返回false
         */
        public boolean isEnemyDead() {
            return curHp <= 0;
        }
    }